<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="材料类别" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/dtree.css" rel="stylesheet" type="text/css">
<script src="/js/dtree.js"></script>
<script language="javascript">
	function doTreeNodeClick(id){
		document.getElementById("currentId").value=id;
		parent.document.getElementById("mainFrame").src="/base/ProductList.ihtm?type_id="+id;
	}
	function doNew(){
		var parentId=document.getElementById("currentId").value;
		var url="/base/ProductTypeNew.ihtm?parent_id="+parentId;
		parent.ShowIframeNoScroll("材料类别",url,320,280,"refreshTypeWin()");//refreshTypeWin是父窗口的
	}
	function refreshWin(defId){//父窗口的refreshTypeWin调用
		window.location="/base/ProductTypeList.ihtm?default_id="+defId;
	}
	function doEdit(){
		var id=document.getElementById("currentId").value;
		if(id==""){
			parent.ShowAlert('提示框','请选择要修改的类别',200,100);
		}else{
			var url="/base/ProductTypeEdit.ihtm?id="+id;
			parent.ShowIframeNoScroll("材料类别",url,320,280,"refreshTypeWin()");//refreshTypeWin是父窗口的
		}
	}
	function doDelete(){
		var id=document.getElementById("currentId").value;
		if(id==""){
			parent.ShowAlert('提示框','请选择要删除的类别',200,100);
		}else{
			parent.ShowConfirm('确认框','确定删除吗？',340,80,"doDelType("+id+")");//doDelType是父窗口的
		}
	}
	function doDelAct(id){//父窗口的doDelType调用
		var fromUrl=getFromUrl();
		window.location="/base/ProductTypeDelete.ihtm?id="+id+"&from_url="+fromUrl;
	}
	function doInit(){
		var defaultId="${defaultId}";
		if(defaultId!=""){
			doTreeNodeClick(defaultId);
			d.openTo(defaultId,true,false);
		}
	}
	function getFromUrl(){
		var defaultId="${defaultId}";
		var fromUrl="/base/ProductTypeList.ihtm?default_id="+defaultId;
		return encodeURIComponent(fromUrl);
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();" style="text-align:center" scroll="no">
			<div class="nav" id="scrollDiv" style="text-align:left;overflow-x:hidden;overflow-y:auto;width:190px;height:508px">
			  <h3 class="title">材料类别</h3>
			  <div class="nav-link nav-mail" style="width:100%">
						<img src="/images/icon_add.gif" border="0" title="新增材料类别" onClick="doNew();" style='cursor:pointer;'/>&nbsp;
						<img src="/images/icon_edit.gif" border="0" title="修改材料类别" onClick="doEdit();" style='cursor:pointer;'/>&nbsp;
						<img src="/images/icon_del.gif" border="0" title="删除材料类别" onClick="doDelete();" style='cursor:pointer;'/>
						<input type="hidden" id="currentId" name="currentId" value="">							
						<div class="blank12"></div>
						<%@include file="../inc/AlertMsg.jsp"%>
						<script language="javascript">
							<!--
							var isOpen=false;
							var d = new dTree('d','/images/dtree');
							
							d.config.useCookies=false;
							d.config.useLines=true;
							d.config.useIcons=true;
							
							d.add(0,-1,'Root');
							<c:forEach var="item" items="${productTypeList}">
								d.add(${item.id},${item.parentId},'<c:out value="${item.typeName}" />',"javascript:doTreeNodeClick('${item.id}');",'','','',false);
							</c:forEach>
							
							document.write(d);
							d.closeAll();
							//-->
						</script>
			  </div>
			</div>
</body>
</html>